//
//  WNLockCollectionViewCell.swift
//  WNLockDemo
//
//  Created by 裴威 on 31/08/2018.
//  Copyright © 2018 wunu. All rights reserved.
//

import UIKit

@objc protocol WNLockCollectionViewCellDelegate: NSObjectProtocol {
    @objc optional func wnLockCollectionViewCellClickForTempkey(cell: WNLockCollectionViewCell)
    @objc optional func wnLockCollectionViewCellClickForAuthUsers(cell: WNLockCollectionViewCell)
    @objc optional func wnLockCollectionViewCellClickForOpenRecord(cell: WNLockCollectionViewCell)
    @objc optional func wnLockCollectionViewCellClickForQrCode(cell: WNLockCollectionViewCell)
    @objc optional func wnLockCollectionViewCellClickForSetting(cell: WNLockCollectionViewCell)
    @objc optional func wnLockCollectionViewCellClickForOpeningLock(cell: WNLockCollectionViewCell)
}
class WNLockCollectionViewCell: UICollectionViewCell {

    @IBOutlet weak var wrapperContentView: UIView!
    @IBOutlet weak var wrapperView: UIView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var batteryLabel: UILabel!
    @IBOutlet weak var signalLabel: UILabel!
    @IBOutlet weak var macAddrLabel: UILabel!
    @IBOutlet weak var bleStatusButton: UIButton!
    @IBOutlet weak var memberRoleLabel: UILabel!
    @IBOutlet weak var bleStatusLabel: UILabel!
    
    weak var delegate: WNLockCollectionViewCellDelegate?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        wrapperContentView.layer.cornerRadius = 4
        wrapperContentView.layer.shadowColor = Colors(hex: 0x999999).cgColor
        wrapperContentView.layer.shadowOffset = CGSize(width: 0, height: 0)
        wrapperContentView.layer.shadowRadius = 10
        wrapperContentView.layer.shadowOpacity = 0.5
        //===
        bleStatusButton.layer.cornerRadius = 64
        bleStatusButton.layer.borderColor = UIColor(hex: 0x333333).cgColor
        bleStatusButton.layer.borderWidth = 3
    }
    /// 点击临时秘钥
    @IBAction func handleClickTempKeyEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForTempkey?(cell: self)
    }
    /// 点击授权成员
    @IBAction func handleClickAuthUsersEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForAuthUsers?(cell: self)
    }
    /// 点击开锁记录
    @IBAction func handleClickOpenRecordEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForOpenRecord?(cell: self)
    }
    /// 点击锁二维码
    @IBAction func handleClickLockQrCodeEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForQrCode?(cell: self)
    }
    @IBAction func handleSettingEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForSetting?(cell: self)
    }
    /// 点击开锁
    @IBAction func handleOpenLockEvent(_ sender: UIButton) {
        delegate?.wnLockCollectionViewCellClickForOpeningLock?(cell: self)
    }
}
